package com.ha.springcloud.controller;


import com.ha.springcloud.pojo.Employee;
import com.ha.springcloud.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginCotroller {
    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("/user/login")
    public String login(@RequestParam("Id") String id, @RequestParam("password") String password, Model model){

        Employee employee=employeeService.queryEmployeeById(id);
        if (employee==null)
        {
            model.addAttribute("msg","用户不存在");
            return "index";
        }
        if(employee.getPassword().equals(password)){
            return "dashboard";
        }else {
            model.addAttribute("msg","用户名或者密码错误");
            return "index";
        }



    }

}
